package three_Thread;

public class MyRunnableDemo {
    public static void main(String[] args) {
        MyRunnable my = new MyRunnable();

//        Thread t1 = new Thread(my, "高铁");
//        Thread t2 = new Thread(my, "飞机");
//        t1.start();
//        t2.start();
//        System.out.println("**********");
//        System.out.println(t1.getPriority());
//        System.out.println(t2.getPriority());

        // 只是创建了，没运行
//        Thread t3 = new Thread(new Runnable() {
//            @Override
//            public void run() {
//                for (int i = 0; i < 10; i++) {
//                    System.out.println(Thread.currentThread().getName() + " : " + i);
//                }
//            }
//        });

        // 加上运行
//        new Thread(new Runnable() {
//            @Override
//            public void run() {
//                for (int i = 0; i < 10; i++) {
//                    System.out.println(Thread.currentThread().getName() + " : " + i);
//                }
//            }
//        }).start();

        // 试试lambda表达式
        new Thread(() -> System.out.println("lambda表达式")).start();

        new Thread(() -> {
            for (int i = 0; i < 11; i++) {
                System.out.println(Thread.currentThread().getName() + " : " + i);
            }
        }, "A").start();

        new Thread(() -> {
            for (int i = 0; i < 11; i++) {
                System.out.println(Thread.currentThread().getName() + " : " + i);
            }
        }, "B").start();

        for (int i = 0; i < 11; i++) {
            System.out.println(Thread.currentThread().getName() + " : " + i);
        }
    }
}
